# Add a spec file, just for fun, even if they are not redhat
#
# make a spec file
sed -e "s/_RELEASE_/$RELEASE/g;s/_VERSION_/$VERSION/g" < libmozjs.spec.template > ${DEST}/libmozjs.spec


RPM=`which rpm`
if [ $? -ne 0 ]; then
    echo "No rpm... all done\n"
    exit 0
fi

echo "BUILDING RPM NATIVE VERSION"

# set up build directory
TOPDIR=`rpm --eval '%{_topdir}'`
mkdir -p ${TOPDIR}/BUILD
mkdir -p ${TOPDIR}/RPMS
mkdir -p ${TOPDIR}/RPMS/i386
mkdir -p ${TOPDIR}/RPMS/i686
mkdir -p ${TOPDIR}/RPMS/x86_64
mkdir -p ${TOPDIR}/SOURCES
mkdir -p ${TOPDIR}/SPECS
mkdir -p ${TOPDIR}/SRPMS


rpmbuild -ta ${TARBALL}

echo "BUILDING 32 BIT VERSION"
CC='gcc -m32' CXX='g++ -m32' linux32 rpmbuild --target i686 -ta ${TARBALL}

# why am I doing this?
echo "COPYING TO CURRENT DIRECTORY"
cp ${TOPDIR}/RPMS/x86_64/${NAME}.x86_64.rpm .
cp ${TOPDIR}/RPMS/i686/${NAME}.i686.rpm .
cp ${TOPDIR}/SRPMS/${NAME}.src.rpm .

NAME=libmozjs-devel-${VERSION}-${RELEASE}
cp ${TOPDIR}/RPMS/x86_64/${NAME}.x86_64.rpm .
cp ${TOPDIR}/RPMS/i686/${NAME}.i686.rpm .

